package com.naiterui.ehp.bs.cms.modules.devops.controller;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.security.annotation.SysLog;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.cms.modules.devops.service.ISysInitFileConfigService;
import com.naiterui.ehp.bs.cms.modules.devops.vo.SysInitFileConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统初始化文件配置
 * 
 * @author yangfuya
 * @since 2022/4/26
 */
@Slf4j
@Validated
@Api(tags = {SwaggerTag.CMS + SwaggerTag.DEVOPS})
@RestController
@RequiredArgsConstructor
@RequestMapping("/devops/sys/init/file/config")
@PreAuthorize("@p.check('devops:sysInitFile')")
public class SysInitFileConfigController {

    private final ISysInitFileConfigService sysInitFileConfigService;

    @SysLog("系统初始化文件配置列表")
    @ApiOperation("系统初始化文件配置列表")
    // @PreAuthorize("@p.check('devops:sysInitFile:list')")
    @GetMapping("list")
    public List<SysInitFileConfigVO> list() {
        return this.sysInitFileConfigService.list();
    }

    @SysLog("系统初始化文件配置检查")
    @ApiOperation("系统初始化文件配置检查")
    // @PreAuthorize("@p.check('devops:sysInitFile:check')")
    @GetMapping("check")
    public void checkConfig(Long id) throws BusinessException {
        this.sysInitFileConfigService.checkConfig(id);
    }
}
